<template>
  <div class="header">
    <div class="header-container">
      <div class="logo fl">
        <a href="">
          <img src="../../assets/images/logo.png" alt="">
        </a>
      </div>
      <div class="nav">
        <div class="nav-inner" >
          <ul :class="{'fade-out':isSearchBtnClick}">
            <li>
              <a href="#">OnePlus5</a>
            </li>
            <li>
              <a href="#">商城</a>
            </li>
            <li>
              <a href="#">服务</a>
            </li>
            <li>
              <a href="#">博客</a>
            </li>
            <li>
              <a href="#">论坛</a>
            </li>
          </ul>
          <form class="search-form" :class="{'slide-in':isSearchBtnClick}">
            <div class="show-menu">
              <div class="" ></div>
            </div>

            <div class="input-box">
              <input class="search-input " type="text" autofocus placeholder="请输入您要搜索的商品名称">
              <button class="search-submit" type="submit"></button>
            </div>
              <div class="hot-search">
                <ul>
                  <li><a href="#">OnePlus 3T</a></li>
                  <li><a href="#">一加DASH闪充</a></li>
                  <li><a href="#">一加3T个性保护壳</a></li>
                </ul>
              </div>
          </form>
        </div>

      </div>

      <div class="btn-box" >
        <a href="#" class="search-btn" @click.prevent="isSearchBtnClick=!isSearchBtnClick" :class="{'btn-clicked':isSearchBtnClick}"></a>
        <a href="#" :class="{'fade-out':isSearchBtnClick}"></a>
        <router-link to="login" :class="{'fade-out':isSearchBtnClick}"></router-link>
        <a href="#"></a>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'home-nav',
    data () {
      return {
        isSearchBtnClick: false
      }
    },
    methods: {

    }
  }
</script>

<style scoped>
  .header {
    width:100%;
  }
  .header-container {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    height: 80px;
  }
  .logo {
    margin-top: 18px;
    margin-left: 20px;
  }
  .nav {
    padding-left: 205px;
    padding-right: 205px;
  }
  .nav-inner {
    position: relative;
  }
  /*点击搜索按钮时添加class fade-out*/
  .nav-inner>ul {
    text-align: center;
    height: 80px;
    opacity: 1;
    z-index: 2;
    transition: opacity .3s .6s,left .3s .3s;
  }
  .nav-inner>ul.fade-out {
    opacity: 0;
    z-index: 1;
    transition: opacity .3s cubic-bezier(0.65, 0.05, 0.36, 1),left .3s cubic-bezier(.645,.045,.355,1);
  }
  .nav-inner>ul>li {
    display: inline-block;
    vertical-align: bottom;
  }
  .nav-inner>ul>li>a {
    position: relative;
    display: block;
    padding-left: 30px;
    padding-right: 30px;
    font-size: 16px;
    line-height: 80px;
    text-align: center;
    color: #7e7e7e;
    overflow: hidden;
    transition: color linear .2s;
  }
  .nav-inner>ul>li>a:hover{
    color: #000;
  }
  .nav-inner>ul>li>a:before {
    content: '';
    display: inline-block;
    position: absolute;
    left:0px;
    bottom: -5px;
    height: 5px;
    width: 100%;
    background-color: #eb0028;
    -webkit-transition: bottom linear .3s;
  }

  /*nav 列表项hover状态添加 class active*/
  .nav-inner>ul>li.active>a:before{
    bottom: 0px;
  }

  .search-form{
    height: 80px;
    position: absolute;
    top: 0px;
    right: 0px;
    width:80%;
    z-index: 1;
    visibility: hidden;
  }
  /*点击搜索按钮时添加class .fade-in*/
  .search-form.slide-in {
    z-index: 2;
    visibility: visible;
  }
  .search-form .input-box {
    width:100%;
    padding-left: 24px;
    position: relative;
    overflow: hidden;
    opacity:0;
    margin-left: 30px;
    transition: all .3s .3s;
    z-index:0;
  }
  /*点击搜索按钮时添加class slide-in*/
  .slide-in .input-box {
    opacity: 1;
    margin-left: 0px;
    transition: all .3s .3s linear;
  }
  .input-box>.search-input {
    height: 80px;
    width: 90%;
    border:none;
    font-size: 16px;
    text-indent: 14px;
  }
  .input-box>.search-input:focus {
    outline: none;
  }
  .input-box>.search-submit{
    position: absolute;
    left: 0px;
    top:50%;
    margin-top: -12px;
    width: 24px;
    height: 24px;
    border:none;
    padding: 0;
    cursor: pointer;
    background-color: transparent;
    background-image: url("../../assets/images/icons-search.png");
    background-repeat: no-repeat;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: 22px 22px;
  }
  .search-form .hot-search {
    position: absolute;
    top: 80px;
    left: 0px;
    width:100%;
    max-height: 0px;
    overflow: hidden;
    background-color: #ffffff;
    transition: all  linear .3s;
  }
  /*点击搜索按钮时添加class slide-top*/
  .search-form.slide-in .hot-search {
    max-height: 200px;
    transition: max-height .5s linear .4s;
  }
  .hot-search>ul{
    padding-left: 20px;
    padding-right: 20px;
    display: block;
  }
  .hot-search>ul>li{
    margin:10px 0px;
  }
  .hot-search>ul>li>a{
    display: block;
    line-height: 30px;
    color: #666;
    padding: 0 10px;
  }
  .hot-search>ul>li>a:hover {
    background-color: #DBDBDB;
  }
  .btn-box {
    position: absolute;
    right:0px;
    top: 8px;
  }

  .btn-box>a{
    display: inline-block;
    width:24px;
    height: 24px;
    padding: 20px;
    box-sizing: content-box;
    vertical-align: bottom;
  }
  .btn-box>a:nth-child(1){
    background-image: url("../../assets/images/icons-search.png");
    background-position: center center;
    background-size: 22px 22px;
    background-repeat: no-repeat;
  }
  /*点击搜索按钮时添加class btn-clicked*/
  .btn-box>a.btn-clicked:nth-child(1){
    background-image: url("../../assets/images/icon_close.png");
    background-size: 15px 15px;
  }
  .btn-box>a.btn-clicked:nth-child(1):hover{
    background-image: url("../../assets/images/icon_close.png");
    background-size: 15px 15px;
  }
  .btn-box>a:nth-child(2){
    background-image: url("../../assets/images/icon_shopcart.png");
    background-position: center center;
    background-size: 22px 22px;
    background-repeat: no-repeat;
    transition: all linear .3s;
  }
  /*点击搜索按钮时添加class fade-out*/
  .btn-box>a.fade-out:nth-child(2) {
    opacity: 0;
  }
  .btn-box>a:nth-child(3){
    background-image: url("../../assets/images/icon_person.png");
    background-position: center center;
    background-size: 24px 24px;
    background-repeat: no-repeat;
    transition: all linear .3s;
  }
  /*点击搜索按钮时添加class fade-out*/
  .btn-box>a.fade-out:nth-child(3) {
    opacity: 0;
  }
  .btn-box>a:nth-child(4){
    background-image: url("../../assets/images/icon_menu.png");
    background-position: center center;
    background-size: 22px 22px;
    background-repeat: no-repeat;
    display: none;
  }

  .btn-box>a:nth-child(1):hover{
    background-image: url("../../assets/images/icons-search-hover.png");
  }
  .btn-box>a:nth-child(2):hover{
    background-image: url("../../assets/images/icon_shopcart_hover.png");
  }
  .btn-box>a:nth-child(3):hover{
    background-image: url("../../assets/images/icon_person_hover.png");
  }
  .btn-box>a:nth-child(4):hover{
    background-image: url("../../assets/images/icon_menu_hover.png");
  }
  .show-menu {
    display: none;
  }

  @media screen and (max-width:991px) {
    .nav {
      padding-left: 75px;
      padding-right: 180px;
    }
    .nav-inner>ul>li>a {
      padding-left: 25px;
      padding-right: 25px;
    }
  }
  @media screen and (max-width:767px) {
    .nav {
      padding-left: 0px;
      padding-right: 0px;
      position: absolute;
      top: 80px;
      left:0px;
      width:100%;
      background: #f3f3f3;
      display: none;
    }
    .nav-inner {
      padding: 20px;
      padding-bottom: 0;
      z-index: 10;
      background-color: #ffffff;
    }
    .nav-inner>ul {
      height:auto;
    }
    .nav-inner>ul>li {
      display: block;
      border-bottom: 1px solid #e3e3e3;
    }
    .nav-inner>ul>li:last-child {
      border: none;
    }
    .nav-inner>ul>li>a {
      text-align: left;
      line-height: 45px;
      padding-left: 15px;
      padding-right: 15px;
    }
    .search-form{
      height: auto;
      position: relative;
      width: 100%;
      z-index: 2;
      margin-bottom: 20px;
      visibility: visible;
    }
    .search-form .input-box {
      width:100%;
      opacity:1;
      margin-left: 0px;
      padding-left: 0px;
    }
    .input-box>.search-input {
      height: auto;
      line-height: normal;
      padding: 15px 0;
      width:100%;
    }
    .input-box>.search-submit{
      left:93%;
    }
    .btn-box>a:nth-child(1){
      display: none;
    }
    .btn-box>a:nth-child(4){
      display: inline-block;
    }
    .btn-box>a:nth-child(2),
    .btn-box>a:nth-child(4) {
      background-size: 24px 24px;
    }
    .btn-box>a:nth-child(3){
      background-size: 26px 26px;
    }
    .show-menu {
      height: 40px;
      position: absolute;
      top: -40px;
      width: 100%;
      background: #f3f3f3;
      z-index: 10;
      text-align: center;
      display: block;
    }
    .show-menu div {
      margin-top: 5px;
      display: inline-block;
      width: 40px;
      height: 30px;
      transition: all .3s;
    }
    .show-menu>div:before,
    .show-menu>div:after {
      content: '';
      display: inline-block;
      width: 12px;
      height: 1px;
      background: #7e7e7e;
      transition: transform .3s;
    }
    .show-menu>div:before {
      transform: rotate(-40deg);
      transform-origin: 100% 50%;
    }
    .show-menu>div:after {
      transform: rotate(40deg);
      transform-origin: 0 50%;
    }
  }

</style>
